<template>
  <div class="WriteEditor">
    <div class="" align="center">
      <h1 style="padding-top: 150px;padding-left: 50px;text-align: center;font-family: 华文行楷;font-weight: bold">发布通知
      </h1>
      <el-form
          :model="writerNoticeForm"
          :rules="loginRules"
          ref="writerArticleForm"
          label-width="60px"
          label-position="right"
          style="padding-left: 400px"
      >
        <el-form-item label="管理员:" prop="adminId" style="padding-left: 18px;padding-top: 20px">
          <el-row>
            <el-col :span="2">
              <span class="el-icon-lock"></span>
            </el-col>
            <el-col :span="22">
              <el-input
                  class="inps"
                  name="adminId"
                  type="textarea"
                  placeholder="管理员Id"
                  v-model="writerNoticeForm.adminId"
                  style="height: 50px;width: 300px"
              ></el-input>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="时间:" prop="declareDate" style="padding-left: 28px">
          <el-row>
            <el-col :span="2">
              <span class="el-icon-lock"></span>
            </el-col>
            <el-col :span="22">
              <el-input
                  class="inps"
                  name="declareDate"
                  type="text"
                  placeholder="declareDate"
                  v-model="writerNoticeForm.declareDate"
              ></el-input>
            </el-col>
          </el-row>
        </el-form-item>

        <el-form-item label="内容:" prop="noticeBody" style="margin-top: 10px;">
          <el-row>
            <el-col :span="2">
              <span class="el-icon-s-custom"></span>
            </el-col>
            <el-col :span="22">
              <el-input
                  class="inps"
                  name="noticeBody"
                  type="textarea"
                  :autosize="{ minRows: 8, maxRows: 8 }"
                  placeholder="请输入通知内容"
                  v-model="writerNoticeForm.noticeBody"
                  style="width: 500px;height: 150px"
              >
              </el-input>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item style="margin-top: 55px">
          <el-button type="primary" round class="submitBtn" @click="submitNotice" color="black"
          ><h3 style="color:white;">发布通知</h3>
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import request from "@/utils/request";
import router from "@/router";

export default {
  name: "AdminNoticeEditor",
  components:{

  },

  created() {
    this.load()
  },

  methods:{
    load(){
    },

    submitArticle(){
      request.post("/articles/writeArticle/"+this.userId+"/"+this.writerNoticeForm.declareDate+"/"+this.writerNoticeForm.summary).then(res => {
        console.log(res.data)
        if (res.data == 500) {
          alert("用户id返回错误,返回推荐文章页面!")
          router.push("/CommentView")
        } else {
          alert("发布成功,返回最新文章")
          router.push("/NowView")
        }
      })
    },

  },

  data(){
    return{
      writerNoticeForm:{
        title:'',
        userId: '',
        declareDate: new Date().getFullYear()+"-"+(new Date().getMonth()+1).toString().padStart(2,'0')+"-"+new Date().getDate().toString().padStart(2,'0')+" "+new Date().getHours().toString().padStart(2,'0')+":"+new Date().getMinutes().toString().padStart(2,'0')+":"+new Date().getSeconds().toString().padStart(2,'0'),
      },

    }
  }
}
</script>

<style>
.WriteEditor{
  /*background-image: url("~@/assets/images/shangan.png");*/

  margin:0px;
  background-size:100% 100%;

  background-attachment:fixed;

  width: 1270px;
  height: 750px;
}
</style>